package com.yzh.chatgpt.model;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.yzh.chatgpt.common.Constants;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * ChatGPT 聊天信息描述
 */
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
@NoArgsConstructor
public class Message {
    /** 角色 */
    private String role;
    /** 内容 */
    private String content;
    /** 姓名：区分相同角色的参与者 */
    private String name;
    
    public Message(Builder builder) {
        this.role = builder.role;
        this.content = builder.content;
        this.name = builder.name;
    }
    public static Builder builder() {
        return new Builder();
    }
    public static final class Builder {
        private String role;
        private String content;
        private String name;

        public Builder() {
        }

        public Builder role(Constants.Role role) {
            this.role = role.getCode();
            return this;
        }

        public Builder content(String content) {
            this.content = content;
            return this;
        }

        public Builder name(String name) {
            this.name = name;
            return this;
        }
        
        public Message build() {
            return new Message(this);
        }
    }
}
